package cn.seecoder.ai.controller;

import cn.seecoder.ai.enums.AnalysisFunctionEnum;
import cn.seecoder.ai.enums.MachineLearningAlgorithmEnum;
import cn.seecoder.ai.model.vo.ResultVO;
import cn.seecoder.ai.service.InstructionService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author DingXiaoyu
 * @date 2023/4/12 15:00
 */
@Slf4j
@RestController
@RequestMapping("${apiPrefix}/instructions")
public class InstructionController {

    @Autowired
    InstructionService instructionService;

    @ApiOperation("分析方法参数学习")
    @GetMapping("/MethodParameterLearn")
    public ResultVO<Object> methodParameterLearn(){
        List<AnalysisFunctionEnum> list=new ArrayList<>();
        list.add(AnalysisFunctionEnum.DATA_DISTRIBUTION);
        list.add(AnalysisFunctionEnum.SCATTER_PLOT);
        list.add(AnalysisFunctionEnum.STATISTICS);
        list.add(AnalysisFunctionEnum.SKEWNESS_KURTOSIS);
        list.add(AnalysisFunctionEnum.PEARSON);
        return ResultVO.buildSuccess(list);
    }

    @ApiOperation("模型参数学习")
    @GetMapping("/ModelParameterLearn")
    public ResultVO<Object> modelParameterLearn(){
        List<MachineLearningAlgorithmEnum> list=new ArrayList<>();
        list.add(MachineLearningAlgorithmEnum.DECISION_TREE_CLASSIFICATION);
        list.add(MachineLearningAlgorithmEnum.GRADIENT_BOOSTED_TREE_CLASSIFICATION);
        list.add(MachineLearningAlgorithmEnum.K_MEANS_CLUSTERING);
        list.add(MachineLearningAlgorithmEnum.LOGISTIC_REGRESSION_CLASSIFICATION);
        list.add(MachineLearningAlgorithmEnum.MULTILAYER_PERCEPTRON_CLASSIFICATION);
        list.add(MachineLearningAlgorithmEnum.NAIVE_BAYES_CLASSIFICATION);
        list.add(MachineLearningAlgorithmEnum.RANDOM_FOREST_CLASSIFICATION);
        list.add(MachineLearningAlgorithmEnum.RANDOM_FOREST_REGRESSION);
        list.add(MachineLearningAlgorithmEnum.XGBOOST_CLASSIFICATION);
        return ResultVO.buildSuccess(list);
    }

    @ApiOperation("参考案例学习")
    @GetMapping("/CaseLearn")
    public ResultVO<Object> caseLearn(@RequestParam Integer userId){
        return null;
    }

    /**
     *
     * @param origin 代表了学生使用模型的文件id
     * @param answer 代表了答案文件的id
     * @return
     */
    @ApiOperation("设置答案")
    @PostMapping("/answer")
    public ResultVO<Boolean> setAnswer(@RequestParam(value = "origin")Integer origin,
                                       @RequestParam(value = "answer")Integer answer){
        return ResultVO.buildSuccess(instructionService.setAnswer(origin,answer));
    }

    /**
     *
     * @param predictionId 该次预测的id
     * @return
     */
    @ApiOperation("校对答案")
    @PostMapping("/check")
    public ResultVO<Integer> checkAnswer(@RequestParam(value = "predictionId")Integer predictionId){
        return ResultVO.buildSuccess(instructionService.checkAnswer(predictionId));
    }
}
